import config from './config'
export default function request (options, callBack, errCallback) {
  let { method = 'get', url, data} = options
  let host = ''
  let path = ''
  if (url.match(/[a-zA-z]+:\/\/[^/]*/)) {
    host = url.match(/[a-zA-z]+:\/\/[^/]*/)[0]
    path = url.slice(host.length)
  } else {
    host = config.host
    path = url
  }
  url = host + path
  let parData = data
  uni.request({
	  method:method,
	  url: url,
	  data: parData,
	  header: {
		'Authorization': authorization
	  },
	  complete: (res) => {
		callBack(res.data)
		// this.$utils.hideLoading()
	  },
	  fail: (err) => {
		  errCallback(err)
	  },
  });
}
